package cn.yx.framework.exception;

import java.util.HashMap;

public class DatabaseException extends BasicException {
    private static final int CODE_DATABASE_ACCESS_EXCEPTION = 5200;
    private String tableName;
    private String primaryKey;

    public DatabaseException() {
        this("数据库访问失败", (String)null, (String)null);
    }

    public DatabaseException(String tableName, String primaryKey) {
        this("数据库访问失败", tableName, primaryKey);
    }

    public DatabaseException(String message, String tableName, String primaryKey) {
        super(5200, message);
        this.tableName = tableName;
        this.primaryKey = primaryKey;
    }

    protected String getFilter() {
        return "com.mysql";
    }

    protected Object getData() {
        return null == this.tableName && null == this.primaryKey?null:new HashMap() {
            {
                this.put("table", DatabaseException.this.tableName);
                this.put("rowPK", DatabaseException.this.primaryKey);
            }
        };
    }
}
